package com.ibiaoke.boss.controller;

import com.ibiaoke.boss.entity.SysUser;
import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.GoodStock;
import com.ibiaoke.goods.service.GoodStockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import java.util.List;

@Controller
public class BossGoodStockController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private GoodStockService goodStockService;


    @RequestMapping("/addStock")
    @ResponseBody
    public Res addStock(GoodStock goodStock,Integer shopId){
        SysUser user = getLoginUser();
        goodStockService.addGoodStock(user.getUserName(),shopId,goodStock);
        logger.info("系统用户{}正在添加库存操作",user.getUserName());
        return Res.create();
    }


    @RequestMapping("/findGoodStockList")
    @ResponseBody
    public Res findStock(String goodName, Integer id, Integer goodId,Date buyTime,Date buyEndTime,String supplier,
                         String buyPro,String buyCity,Integer shopId,Page page) {
        List<GoodStock> goodStockList =  goodStockService.findGoodStockList(goodName,id,goodId,buyTime,
                buyEndTime,supplier, buyPro, buyCity,shopId,page);
        return  Res.create().addResponse("goodStockList", goodStockList).addResponse("page",page);
    }

}